/************************************\
|* unittest2.c                      *|
|* By Danny Burrows                 *|
|* burrowsd@onid.oregonstate.edu    *|
|* CS362 - Spring 2014              *|
|*                                  *|
|* Assignment 3                     *|
|*                                  *|
|* Simple unit tests of the         *|
|* gainCard function inside of      *|
|* dominion.c                       *|
\************************************/

#include <stdio.h>
#include <stdlib.h>
#include "dominion.h"

void checkTest(char *string, int expected, int result)
{
	if (expected == result)
		printf("PASS - %s: expected - %d, result - %d\n", string, expected, result);
	else
		printf("FAIL - %s: expected - %d, result - %d\n", string, expected, result);

	return;
}

void runTests(struct gameState *game)
{
	/* Run unit tests */
	int supplySize = rand() % 10;
	/* set supply count for enum 0 to 10 */
	game->supplyCount[0] = supplySize;
	/* set player 1 deck count to 10 */
	game->deckCount[0] = supplySize;
	checkTest("supplyCount[0]", supplySize, game->supplyCount[0]);
	checkTest("deckCount[0]", supplySize, game->deckCount[0]);
	/* pull a card from deck 0 and to player 0's hand */
	for (int i = 1; i < (rand() % 10) + 5; i++)
	{
		if ( (gainCard(0, game, 1, 0)) != -1) {
			checkTest("supplyCount[0]", (supplySize - i), game->supplyCount[0]);
			checkTest("deckCount[0]", (supplySize + i), game->deckCount[0]);
		}
	}
	return;
}

int main(int argc, char const *argv[])
{
	struct gameState *game = malloc(sizeof(struct gameState));

	runTests(game);
	free(game);
	return 0;
}